package com.gaofei.jpa.dao;

import com.gaofei.jpa.entity.Dept;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**

 */
public interface DeptRepository extends CrudRepository<Dept,Long> {

    /**
     * 根据层级查找
     *
     * @param codeLink 层级
     * @return
     * @author lihy
     */
    List<Dept> findByCodeLink(Integer codeLink);

    /**
     * 获取最新的id
     *
     * @return java.lang.Long
     * @author lihy
     */
    @Query(value = "select id from dept order by id desc limit 1", nativeQuery = true)
    Long getLatestId();

}
